<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <input type="checkbox" id="test"  name="xfz" />
    <input type="button"  id="btn" value="test" />
</body>
<script type="text/javascript">
    var testNode  =document.querySelector("#test");
    btn.onclick=function(){
        testNode.setAttribute("checked","checked")
    }
</script>
</html>
